package ioc

import (
	"gitee.com/DonHz/basic-go/webook/internal/service/sms"
	"gitee.com/DonHz/basic-go/webook/internal/service/sms/memory"
	"gitee.com/DonHz/basic-go/webook/internal/service/sms/tencent"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
	tencentSMS "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111"
	"os"
)

func InitSMSService() sms.Service {
	// 替换内存还是别的
	return memory.NewService()
}

func InitSmsTencentService() sms.Service {
	secretId, ok:= os.LookupEnv("SMS_SECRET_ID")
	if !ok {
		panic(any("没有找到环境变量：SMS_SECRET_ID"))
	}
	secretKey, ok:= os.LookupEnv("SMS_SECRET_KEY")
	client, err:=tencentSMS.NewClient(common.NewCredential(secretId, secretKey),
		"ap-nanjing",
		profile.NewClientProfile())
	if err!= nil{
		panic(any("没有找到环境变量：SMS_SECRET_KEY"))
	}
	return tencent.NewSmsService(client, "1333689298", "DonHz")
}
